using UnityEngine;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Se agrega a un gameobject vacio en la escena y usando la lista agregas quests.
/// </summary>
public class ObjectiveKillEnemies : MonoBehaviour {

    public List<KillObjectiveInfo> m_ObjectivesToAdd = new List<KillObjectiveInfo>();
	void Awake () 
    {
        foreach (KillObjectiveInfo info in m_ObjectivesToAdd)
        {
            if (info.m_Type == KILLQUESTTYPE.AMOUNT)
            {
                //lo uso tambien para la descripcion del texto.
                string objectiveId = "Kill ";
                if (info.m_TargetsRank == ENEMYRANK.SOLDIER)
                {
                    objectiveId += "soldier";
                }
                else if (info.m_TargetsRank == ENEMYRANK.COMMANDER)
                {
                    objectiveId += "commander";
                }
                QuestCreator.GetInstance().CreateObjective(info.m_QuestPriority, objectiveId, info.m_Amount, objectiveId, "");
            }
            else if(info.m_Type == KILLQUESTTYPE.SPECIFIC)
            {
                if (info.m_SpecificTarget == null)
                {
                    Debug.LogError("Quest esta seteada para target especifico pero el target es null");
                    continue;
                }
                QuestCreator.GetInstance().CreateObjective(info.m_QuestPriority, "Kill " + info.m_SpecificTarget.m_EnemyName, 1, "Kill " + info.m_SpecificTarget.m_EnemyName, "");
                info.m_SpecificTarget.m_IsSpecificTarget = true;
            }
        }
	}
}

/// <summary>
/// //Si la quest es de tipo especifico se ignora el Amount y el target rank.
//  Si es por cantidad se ignora el SpecificTarget
/// </summary>
[System.Serializable]
public class KillObjectiveInfo
{
    public int m_QuestPriority = 0;
    public KILLQUESTTYPE m_Type = KILLQUESTTYPE.AMOUNT;
    public ENEMYRANK m_TargetsRank = ENEMYRANK.SOLDIER;
    public int m_Amount = 5;
    public Enemy m_SpecificTarget = null;
}
/// <summary>
/// AMOUNT: Matar cierta cantidad de enemigos de cierto rango.
/// SPECIFIC: Matar a un enemigo en especifico.
/// </summary>
public enum KILLQUESTTYPE
{
    AMOUNT,
    SPECIFIC
}
